function adminLoginAjax(account, password, check) {
    //2.发送ajax
    $.ajax({
        url: "user/userLogin",
        type: "post",
        data: {
            userName: account,
            userPwd: password,
            check: check
        },
        dataType: "JSON",
        success: function(data) {
            //判断
            if (data.id == 1) {
                //登录成功
                layer.confirm(data.message, {
                    btn: ['确定'] //按钮
                }, function() {
                    //存储用户昵称
                    sessionStorage.setItem("niname", data.datas["user"].userNiname);
                    sessionStorage.setItem("userId", data.datas["user"].userId);
                    location.href = "page?p=" + data.location;
                });
            } else if (data.id == 0) {
                //登录失败
                layer.confirm(data.message, { btn: ['确定'] });
            }
        },
        error: function(data) {

        }
    });
}

$(function() {
    //1.登录按钮的单机事件
    $('#loginBtn').click(function() {
        console.log('点击了登录按钮');
        //1.获取参数
        var account = $('#account').val();
        var password = $('#password').val();
        var check = $('#check').val();
        if (account == "" || password == "" || check == "") {
            layer.confirm('输入框中不能为空,请重新输入', {
                btn: ['确定'] //按钮
            });
        } else {
            adminLoginAjax(account, password, check);
        }
    })
});
/* **************注册按钮***************** */
$('#registerBtn').click(function() {
    location.href = "page?p=Register"
});